<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="/resources/css/table.css?r=3" rel="stylesheet">
    <script src="/resources/js/jquery-1.11.1.min.js"></script>
    <script src="/resources/js/self.js"></script>
    <script type="text/javascript" src="/resources/js/md5.js"></script>
    <script type="text/javascript" src="/resources/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="/resources/js/ajaxfileupload.js"></script>
    <script type="text/javascript" src="/resources/js/Util.js"></script>
    <link  href="/resources/viewer/viewer.css" rel="stylesheet">
    <script src="/resources/viewer/viewer.js"></script>
    <style>
        td{
            width: 25% !important;
        }
    </style>
</head>
<body>
<table>
    <tr>
        <td colspan="2" class="name">运输公司名称</td>
        <td class="value transportCompany" name="name"></td>
    </tr>
    <tr>
        <td colspan="2" class="name">运输汽车</td>
        <td class="value form-data" name="transportCarInfo"></td>
    </tr>
    <tr>
        <td  class="name">
            运输汽车照片
        </td>
        <td colspan="2"  class="name">
            运输人员照片
        </td>
    </tr>
    <tr>
        <td  class="value">
            <div  id="car_div" style="margin-top: 20px;" >
            </div>
        </td>
        <td colspan="2"  class="value">
            <div  id="people_div" style="margin-top: 20px;" >
            </div>
        </td>
    </tr>
    <tr>
        <td class="name" rowspan="4">驾驶员</td>
        <td class="name">姓名</td>
        <td  class="value form-data" name="driverName"></td>

    </tr>
    <tr>
        <td class="name">身份证</td>
        <td  class="value form-data" name="driverCard"></td>
    </tr>
    <tr>
        <td class="name">性别</td>
        <td  class="value form-data" name="driverSex"></td>
    </tr>
    <tr>
        <td class="name">电话</td>
        <td  class="value form-data" name="driverTelephone"></td>
    </tr>
    <tr>
        <td class="name" rowspan="4">押运人</td>
        <td class="name">姓名</td>
        <td  class="value form-data" name="supercargoName"></td>

    </tr>
    <tr>
        <td class="name">身份证</td>
        <td  class="value form-data" name="supercargoCard"></td>
    </tr>
    <tr>
        <td class="name">性别</td>
        <td  class="value form-data" name="supercargoSex"></td>
    </tr>
    <tr>
        <td class="name">电话</td>
        <td  class="value form-data" name="supercargoTelephone"></td>
    </tr>
</table>

</body>
<script type="text/javascript">
    $(function () {
        setTitle("运输信息");
        initData();
    });

    function initData(){

        var data = getData();
        if(null2empty(data["id"]) !==""){
            var id = data.id;
            $("input[name='id']").val(id);
            $.ajax({
                url:"/admin/saleOrder/deepWarpper.do",
                data:{'id':id},
                type:'post',
                dataType:'json',
                success:function(data){
                    console.log(data);
                    if(data.success){
                        data.data.driverSex = sexTrans(data.data.driverSex);
                        data.data.supercargoSex = sexTrans(data.data.supercargoSex);
                        initPageDate(data.data, '.form-data');
                        addFileInfoToTable(data.data.carImageList,'car');
                        addFileInfoToTable(data.data.peopleImageList,'people');
                        initPageDate(data.data.transportCompany, '.transportCompany');
                        addFileInfoToTable(data.data.transportCompany.fileInfoList,'transportCompany');
                    }
                }
            });
            $("#account").attr('readonly','readonly');
        }


    }
    function uploadFile(fileType) {
        $.ajaxFileUpload({
            url: "/file/uploadFile.do?_t=" + new Date().getTime(),            //需要链接到服务器地址
            secureuri: false,//是否启用安全提交，默认为false
            fileElementId: fileType+'_input',                        //文件选择框的id属性
            dataType: 'text',                                     //服务器返回的格式，可以是json, xml
            success: function (data, status) {//服务器成功响应处理函数
                var rpeObj = $.parseJSON(data);
                var fileInfoList = rpeObj.data;
                addFileInfoToTable(fileInfoList,fileType);

            }
        });
    }
    function addFileInfoToTable(fileInfoList,fileType){
        $(fileInfoList).each(function(index,file){
            var fileHtml = "<div  style='border-radius: 2px; width:48%;height:100px;float: left; border: 2px #ffffff solid;'>"+
                "<div style='height:100px;overflow:hidden'><img class='image' style='width:auto;height:100px;' src='"+getFileShowUrl(file.path)+"'></div>"+

                "<div align='center' style='height:80px;margin-bottom: 0px;'>"+
                "</div>";
            $(fileHtml).appendTo($("#"+fileType+"_div"));

        });
        $('.image').viewer();
    }
    //获取要展示的图片
    function getFileShowUrl(url){
        var extStart=url.lastIndexOf(".");
        var ext=url.substring(extStart,url.length).toUpperCase();
        if(ext!=".BMP"&&ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
            return "/resources/images/timg.jpg";
        }else{
            return url;
        }
    }
    function back() {
        var data = getData();
        if(!isNullOrUndefined(data.back_url)){
            goto(data.back_url,{"id":data.back_id});
        }
    }
    function sexTrans(sex) {
        var name = "";
        if("man"===sex){
            name ="男";
        }else if("woman"===sex){
            name ="女";
        }
        return name;
    }
</script>
</html>